package cat.music.ut.comm.http

import android.util.Log
import okhttp3.OkHttpClient
import okhttp3.Request

object OkHttpUtil {
    /**
     * Get请求
     * @param url   URL地址
     * @return  返回结果
     */
    fun get(url: String): String? {
        Log.e(">>", "search: $url" )
        var result: String? = null
        try {
            val okHttpClient = OkHttpClient()
            val request: Request = Request.Builder().url(url).build()
            val response = okHttpClient.newCall(request).execute()
            result = response.body!!.string()
            return result
        } catch (e: Exception) {
            e.printStackTrace()
            return result
        }
    }
}